/**
 *
 * @author
 *
 */
class OpPageBasic extends OpPage {

    private _bgSprite: egret.Bitmap;
    private _words: egret.Bitmap;
    private _touchEnabled: Boolean = false;

    public constructor(resBgName: string, resWordName: string) {
        super();

        this._bgSprite = new egret.Bitmap();
        this._bgSprite.texture = RES.getRes(resBgName);
        this._bgSprite.width = 1200;
        this._bgSprite.height = 750;
        this._bgSprite.x = 0;
        this._bgSprite.y = 0;
        this.addChild(this._bgSprite);

        this._words = new egret.Bitmap();
        this._words.texture = RES.getRes(resWordName);
        this._words.width = 1200;
        this._words.height = 300;
        this._words.x = 0;
        this._words.y = 450;
        this.addChild(this._words);
    }

    public reset(): void {
        this.alpha = 1;
        egret.Tween.get(this._words).set({ alpha: 0 });
    }

    public play(callback?: Function,context?: any): void {
        egret.Tween.get(this._words).to({ alpha: 1 },2000,egret.Ease.cubicInOut).call(function() {
            callback && callback.call(context);
        });
    }

    public enableTouch(): void {
        this._touchEnabled = true;
    }

    public oneTouch(event: egret.TouchEvent): void {
        if(this._touchEnabled) {
            this._touchEnabled = false;
            EventBus.trigger('OP_PLAY_NEXT');
        }
    }
}
